﻿using BLL.Interface;
using Common.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model.DTO.Article;
using Model.DTO.Public.GetList;
using Model.DTO.Public.OperateId;
using System.Data;

namespace TianXiaHuiForumManagementSystem.Controllers.Admin
{
    [Route("Admin/[controller]")]
    [ApiController]
    public class ArticleTypeController : ControllerBase
    {
        private readonly IArticleTypeBLL _articleTypeBLL;
        public ArticleTypeController(IArticleTypeBLL articleTypeBLL)
        {
            _articleTypeBLL = articleTypeBLL;
        }
        /// <summary>
        /// 添加文章类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("AddArticleType")]
        [Authorize(Roles = "Admin")]
        public async Task<string> AddArticleType(AddArticleTypeDTO param)
        {
            var result = await _articleTypeBLL.AddArticleType(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 删除文章类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("DeleteArticleType")]
        [Authorize(Roles = "Admin")]
        public async Task<string> DeleteArticleType(OperateIdDTO_INT param)
        {
            var result = await _articleTypeBLL.DeleteArticleType(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 编辑文章类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("EditArticleType")]
        [Authorize(Roles = "Admin")]
        public async Task<string> EditArticleType(EditArticleTypeDTO param)
        {
            var result = await _articleTypeBLL.EditArticleType(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 获取文章类型列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("GetArticleTypeList")]
        public async Task<string> GetArticleTypeList(GetListDTO param)
        {
            var result = await _articleTypeBLL.GetArticleTypeList(param);
            return result.ToJsonFormat();
        }
    }
}
